﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="author" content="Aowork">
    <meta name="description" content="">
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, maximum-scale=1.0">
    <meta name="apple-mobile-web-app-status-bar-style" content="black" />
    <meta name="format-detection" content="telephone=no">

    <title></title>

    <link href="../css/mobile.css" rel="stylesheet" />

    <script type="text/javascript" src="http://res.wx.qq.com/open/js/jweixin-1.1.0.js"></script>
    <script src="../js/zepto.min.js"></script>
    <script src="../js/zepto.swipe.js"></script>
    <script src="../js/common.js"></script>
    <script src="../js/config.js"></script>
    <script src="../js/uiExtend.js"></script>
    <script src="../js/wx_config.js"></script>

    <script type="text/javascript">
        $(function () {
            jc.ui.header.trigger("updateTitle", "我的购物车");
        });
    </script>

    <script type="text/javascript">
        jc.fnInit.push(function () {
            jc.ui.header.trigger("getUser", function (user) {
                if (!user) {
                    errorRouter("login");
                    return;
                }

                $.getJSON(window.path.shoppingCart, { accessToken: user.accessToken, userId: user.uid }, function (result) {
                    if (result.success) {
                        var data = result.data;
                        var dataArray = [];
                        for (var i = 0, l = data.length; i < l; i++) {
                            data[i].courseInfo.shoppingCartId = data[i].shoppingCartId;
                            data[i].courseInfo.initClass = "checked";
                            dataArray.push(data[i].courseInfo);
                        }
                        jc.ui.courseHolder.filter("source=shoppingCart", "setup", dataArray);
                    }
                    else {
                        errorRouter(result.desc);
                    }
                });

            });
        });


        window.courseHolderItemChange = function ($item) {

            var array = [];

            var $item_checked = $item.filter(".checked");

            $item_checked.each(function (i, obj) {
                var $obj = $(obj);
                array.push($obj.attr("data-shopping-cart-id"));
            });


            if (array.length) {
                jc.ui.header.trigger("getUser", function (user) {
                    $.getJSON(window.path.calDiscount, {
                        accessToken: user.accessToken,
                        userId: user.uid,
                        shoppingCartIds: array.join("|")
                    }, function (result) {
                        console.log(result);
                        if (result.success) {
                            result.data.shoppingCartIds = array;
                            jc.ui.cartListFooter.trigger("setup", result.data);
                        }
                    });

                });
            }
            else {
                var data = { shoppingCartIds: [], discountPrice: 0, payPrice: 0 };
                jc.ui.cartListFooter.trigger("setup", data);
            }



        }

        window.courseHolderItemRemove = function ($item_remove) {
            jc.ui.header.trigger("getUser", function (user) {
                $item_remove.each(function (i, obj) {
                    var $obj = $(obj);
                    $.getJSON(window.path.cartDelect, {
                        accessToken: user.accessToken,
                        userId: user.uid,
                        shoppingCartId: $obj.attr("data-shopping-cart-id")
                    }, function (result) {
                        if (result.success) {
                            window.location.reload();
                        }
                        else {
                            window.errorRouter(result);
                        }
                    });
                });
            });

        }

    </script>

</head>
<body>

    <div data-ui="header" class="J_header">
        <div class="h_inner"></div>
    </div>

    <div class="ptb10 bgfff bb1">

        <div data-ui="courseHolder" data-source="shoppingCart" data-keyword="title,price,label,signAmount" data-click-toggle-class="checked" data-null-tips="购物车空空如也~~" class="J_courseHolder hasCheckbox">
            <div class="c_inner">

            </div>
            <div class="c_controller clearfix">
                <div class="c_left">
                    <div class="l_selectAll">
                        <a href="javascript:;">全选<span>0</span></a>
                    </div>
                </div>
                <div class="c_right">
                    <div class="r_btn">
                        <a class="abtn red" href="javascript:;">删除</a>
                    </div>
                </div>
            </div>
        </div>


    </div>

    <div data-ui="cartListFooter" class="J_cartListFooter">
        <div class="c_inner"></div>

    </div>



    <div data-ui="footer" class="J_footer">


    </div>


    <div data-ui="nav" class="J_nav">
        <div class="n_inner">
            <div class="i_center clearfix"></div>
        </div>
    </div>




</body>
</html>
